*****************************************************************************************************************************************
********FIGURE 1. PAYOFF MATRICES
*****************************************************************************************************************************************

*Only in the paper 
log using "$logpath/02_Figures_JEEA_final", replace
*****************************************************************************************************************************************
********FIGURE 2. DESTRUCTIVE BEHAVIOR IN GROUPS, EXPERIMENT 1 (UNIVERSITY STUDENTS) 
*****************************************************************************************************************************************

**PANEL A: CONDITIONAL DECISION, IF PARTNER NON-DESTRUCTIVE

use "$cleandatapath/Experiment1.dta", clear

preserve

		gen order_help=1 if  Treatment==1 
		replace order_help=2.5 if Treatment==2 
		replace order_help=4 if Treatment==3  
		replace order_help=5.5 if Treatment==4  
		
		collapse  (mean) mean_JD = JD_ifnice (sd) sd_JD = JD_ifnice (count) n_JD = JD_ifnice , by(order_help)
					
		*generate the values of 95% confidence intervals 
			gen hi_JD = mean_JD + invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))
			gen low_JD= mean_JD - invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))			
			
	*generate the label
		gen mean_JD_help=mean_JD
		format mean_JD_help %9.2f
		
		*graph begin
		graph twoway (bar mean_JD order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_JD order_help if order_help==2.5, color(gs10) lcolor(black)) ///
		(bar mean_JD order_help if order_help==4, color(gs5) lcolor(black)) ///
		(bar mean_JD order_help if order_help==5.5, color(gs2) lcolor(black)) ///
		(rcap hi_JD low_JD order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_JD order_help , ///
		msymbol(none) mlabel(mean_JD_help) mlabposition(12) mlabgap(*14) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.35)) ytitle("Proportion of destructive choices in JDG" "Conditional decision, if partner non-destructive") ylabel(0.0(0.05)0.3, nogrid ang(h)) xscale(r(0 6)) xlab(1 "Individual" 2.5 `" "GroupContext" "_Hidden" "' 4  `""GroupContext" "_Observed" "'5.5 "Group", labsize(medsmall) noticks) ///
		xsize(5) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		graph save "$outputpath/Figures/Fig_2A", replace
		graph export "$outputpath/Figures/Fig_2A.pdf", replace
		
restore

**PANEL B: ALL CHOICES (INDEX: 0=MIN, 1=MAX)

use "$cleandatapath/Experiment1.dta", clear

preserve

		gen order_help=1 if  Treatment==1 
		replace order_help=2.5 if Treatment==2 
		replace order_help=4 if Treatment==3  
		replace order_help=5.5 if Treatment==4  
		
		collapse  (mean) mean_JD = JD_index (sd) sd_JD = JD_index (count) n_JD = JD_index , by(order_help)
	
			
		*generate the values of 95% confidence intervals 
			gen hi_JD = mean_JD + invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))
			gen low_JD= mean_JD - invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))			
			
	*generate the label
		gen mean_JD_help=mean_JD
		format mean_JD_help %9.2f
		
		*graph begin
		graph twoway (bar mean_JD order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_JD order_help if order_help==2.5, color(gs10) lcolor(black)) ///
		(bar mean_JD order_help if order_help==4, color(gs5) lcolor(black)) ///
		(bar mean_JD order_help if order_help==5.5, color(gs2) lcolor(black)) ///
		(rcap hi_JD low_JD order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_JD order_help , ///
		msymbol(none) mlabel(mean_JD_help) mlabposition(12) mlabgap(*14) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.35)) ytitle("Proportion of destructive choices in JDG" "All choices (Index: 0=min, 1=max)") ylabel(0.0(0.05)0.3, nogrid ang(h)) xscale(r(0 6)) xlab(1 "Individual" 2.5 `" "GroupContext" "_Hidden" "' 4  `""GroupContext" "_Observed" "'5.5 "Group", labsize(medsmall) noticks) ///
		xsize(5) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		graph save "$outputpath/Figures/Fig_2B", replace
		graph export "$outputpath/Figures/Fig_2B.pdf", replace
		
restore


*****************************************************************************************************************************************
******** FIGURE 3. DESTRUCTIVE BEHAVIOR IN GROUPS, EXPERIMENT 2 (REPRESENTATIVE SAMPLE OF ADULT POPULATION)
*****************************************************************************************************************************************

**PANEL A: CONDITIONAL DECISION, IF PARTNER NON-DESTRUCTIVE

use "$cleandatapath/Experiment2.dta", clear

tab Treatment, nolabel
preserve

		gen order_help=1 if  Treatment==1 
		replace order_help=2.5 if Treatment==2 
		
		collapse  (mean) mean_JD = JD_ifnice (sd) sd_JD = JD_ifnice (count) n_JD = JD_ifnice , by(order_help)
				
		*generate the values of 95% confidence intervals 
			gen hi_JD = mean_JD + invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))
			gen low_JD= mean_JD - invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))			
			
	*generate the label
		gen mean_JD_help=mean_JD
		format mean_JD_help %9.2f
		
		*graph begin
		graph twoway (bar mean_JD order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_JD order_help if order_help==2.5, color(gs10) lcolor(black)) ///
		(rcap hi_JD low_JD order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_JD order_help , ///
		msymbol(none) mlabel(mean_JD_help) mlabposition(12) mlabgap(*14) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.35)) ytitle("Proportion of destructive choices in JDG" "Conditional decision, if partner non-destructive") ylabel(0.0(0.05)0.3, nogrid ang(h)) xscale(r(0 3)) xlab(1 "Individual" 2.5 `" "GroupContext" "_Hidden" "', labsize(medsmall) noticks) ///
		xsize(3) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		graph save "$outputpath/Figures/Fig_3A", replace
		graph export "$outputpath/Figures/Fig_3A.pdf", replace
		
restore

**PANEL B: ALL CHOICES (INDEX: 0=MIN, 1=MAX)

use "$cleandatapath/Experiment2.dta", clear


preserve

		gen order_help=1 if  Treatment==1 
		replace order_help=2.5 if Treatment==2 
 
		
		collapse  (mean) mean_JD = JD_index (sd) sd_JD = JD_index (count) n_JD = JD_index , by(order_help)
										
			
		*generate the values of 95% confidence intervals
			gen hi_JD = mean_JD + invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))
			gen low_JD= mean_JD - invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))			
			
	*generate the label
		gen mean_JD_help=mean_JD
		format mean_JD_help %9.2f
		
		*graph begin
		graph twoway (bar mean_JD order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_JD order_help if order_help==2.5, color(gs10) lcolor(black)) ///
		(bar mean_JD order_help if order_help==4, color(gs5) lcolor(black)) ///
		(bar mean_JD order_help if order_help==5.5, color(gs2) lcolor(black)) ///
		(rcap hi_JD low_JD order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_JD order_help , ///
		msymbol(none) mlabel(mean_JD_help) mlabposition(12) mlabgap(*16) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.35)) ytitle("Proportion of destructive choices in JDG" "All choices (Index: 0=min, 1=max)") ylabel(0.0(0.05)0.3, nogrid ang(h)) xscale(r(0 3)) xlab(1 "Individual" 2.5 `" "GroupContext" "_Hidden" "', labsize(medsmall) noticks) ///
		xsize(3) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		graph save "$outputpath/Figures/Fig_3B", replace
		graph export "$outputpath/Figures/Fig_3B.pdf", replace
		
restore

*****************************************************************************************************************************************
******** FIGURE 4. EFFECT OF A GROUP CONTEXT ON DESTRUCTIVE BEHAVIOR IN THE JOY OF DESTRUCTION GAME — HETEROGENEITY ACROSS SUB-GROUPS, EXPERIMENT 2 (REPRESENTATIVE SAMPLE OF ADULT POPULATION)
*****************************************************************************************************************************************

use "$cleandatapath/Experiment2.dta", clear

eststo clear

recode Treatment (1=0) (2=1), gen(Treatment_GC)

********************************
***Number of observations (to be added manually into the left-most column)

**gender
sum JD_ifnice if Female==0
sum JD_ifnice if Female==1
**age
sum JD_ifnice if age_cat==1
sum JD_ifnice if age_cat==2
sum JD_ifnice if age_cat==3
sum JD_ifnice if age_cat==4
sum JD_ifnice if age_cat==5
sum JD_ifnice if age_cat==6
**size of municipality
sum JD_ifnice if size_place==1
sum JD_ifnice if size_place==2            
sum JD_ifnice if size_place==3            
sum JD_ifnice if size_place==4            
sum JD_ifnice if size_place==5  
**edu 
sum JD_ifnice if edu_5==1 /*edu_5=1 if edu=1 or edu=2*/
sum JD_ifnice if edu==3                
sum JD_ifnice if edu==4                
**HH income - quartiles
sum JD_ifnice if HHinc_1==1
sum JD_ifnice if HHinc_2==1
sum JD_ifnice if HHinc_3==1
sum JD_ifnice if HHinc_4==1
**voting
sum JD_ifnice if voting_p_psl==1
sum JD_ifnice if voting_p_psl==2               
sum JD_ifnice if voting_p_psl==3               

sum JD_ifnice if voting_p_lnk==1
sum JD_ifnice if voting_p_lnk==2               
sum JD_ifnice if voting_p_lnk==3


******************
**Underlying regressions

**gender

quietly eststo het_JD_gender1: reg JD_ifnice Treatment_GC if Female==0, robust
quietly eststo het_JD_gender2: reg JD_ifnice Treatment_GC if Female==1, robust

**age

quietly eststo het_JD_age1: reg JD_ifnice Treatment_GC if age_cat==1, robust
quietly eststo het_JD_age2: reg JD_ifnice Treatment_GC if age_cat==2, robust
quietly eststo het_JD_age3: reg JD_ifnice Treatment_GC if age_cat==3, robust
quietly eststo het_JD_age4: reg JD_ifnice Treatment_GC if age_cat==4, robust
quietly eststo het_JD_age5: reg JD_ifnice Treatment_GC if age_cat==5, robust
quietly eststo het_JD_age6: reg JD_ifnice Treatment_GC if age_cat==6, robust


**size of municipality

quietly eststo het_JD_mun1: reg JD_ifnice Treatment_GC if size_place==1, robust
quietly eststo het_JD_mun2: reg JD_ifnice Treatment_GC if size_place==2, robust            
quietly eststo het_JD_mun3: reg JD_ifnice Treatment_GC if size_place==3, robust            
quietly eststo het_JD_mun4: reg JD_ifnice Treatment_GC if size_place==4, robust            
quietly eststo het_JD_mun5: reg JD_ifnice Treatment_GC if size_place==5, robust  

**edu 

quietly eststo het_JD_educ1: reg JD_ifnice Treatment_GC if edu_5==1, robust /*edu_5=1 if edu=1 or edu=2*/
quietly eststo het_JD_educ2: reg JD_ifnice Treatment_GC if edu==3, robust                
quietly eststo het_JD_educ3: reg JD_ifnice Treatment_GC if edu==4, robust                

**HH income - quartiles

quietly eststo het_JD_hhinc1: reg JD_ifnice Treatment_GC if HHinc_1==1, robust
quietly eststo het_JD_hhinc2: reg JD_ifnice Treatment_GC if HHinc_2==1, robust
quietly eststo het_JD_hhinc3: reg JD_ifnice Treatment_GC if HHinc_3==1, robust
quietly eststo het_JD_hhinc4: reg JD_ifnice Treatment_GC if HHinc_4==1, robust


**voting

quietly eststo het_JD_vote1: reg JD_ifnice Treatment_GC if voting_p_psl==1, robust
quietly eststo het_JD_vote2: reg JD_ifnice Treatment_GC if voting_p_psl==2, robust               
quietly eststo het_JD_vote3: reg JD_ifnice Treatment_GC if voting_p_psl==3, robust               

quietly eststo het_JD_vote4: reg JD_ifnice Treatment_GC if voting_p_lnk==1, robust
quietly eststo het_JD_vote5: reg JD_ifnice Treatment_GC if voting_p_lnk==2, robust               
quietly eststo het_JD_vote6: reg JD_ifnice Treatment_GC if voting_p_lnk==3, robust

***Figure 4A (left part)
  coefplot ///
    (het_JD_gender1, label("") msymbol(O)), bylabel("Male (N=1,895)") || ///
	(het_JD_gender2), bylabel("Female (N=2,348)") || ///
	(het_JD_age1), bylabel("18-24 (N=398)") || ///
	(het_JD_age2), bylabel("25-34 (N=944)") || ///
	(het_JD_age3), bylabel("35-44 (N=1,008)") || ///
	(het_JD_age4), bylabel("45-54 (N=796)") || ///
	(het_JD_age5), bylabel("55-64 (N=746)") || ///
	(het_JD_age6), bylabel("65+ (N=351)") || ///
	(het_JD_mun1), bylabel("<1,000 (N=594)") || ///
	(het_JD_mun2), bylabel("1,000-5,000 (N=1,106)") || ///
	(het_JD_mun3), bylabel("5,000-20,000 (N=727)") || ///
	(het_JD_mun4), bylabel("20,000-100,000 (N=1,189)") || ///
	(het_JD_mun5), bylabel(">100,000 (N=627)") || ///
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.05 0.15)) ///
	legend(rows(1) position(6)  xoffset(-15)) ysize(6) xsize(5)   ///
	keep(Treatment_GC) headings(1="{bf: Gender}" 3="{bf: Age}" 9="{bf: Municipality size}", labcolor(black))
graph save "$outputpath/Figures/Fig_4A", replace
graph export "$outputpath/Figures/Fig_4A.pdf", replace     

***Figure 4B (right part)

    coefplot ///
   	(het_JD_educ1, label("") msymbol(O)), bylabel("Primary/Lower Secondary (N=1,144)") || ///
	(het_JD_educ2), bylabel("Upper Secondary (N=1,772)") || ///
	(het_JD_educ3), bylabel("Tertiary (N=1,327)") || ///
	(het_JD_hhinc1, label(Effect of GC_Hidden) msymbol(O)), bylabel("1st quartile (N=1,066)") || ///
	(het_JD_hhinc2), bylabel("2nd quartile (N=1,272)") || ///
	(het_JD_hhinc3), bylabel("3rd quartile (N=1,406)") || ///
	(het_JD_hhinc4), bylabel("4th quartile (N=499)") || ///
	(het_JD_vote1), bylabel("Right (N=1,405)") || ///
	(het_JD_vote2), bylabel("Middle (N=907)") || ///
	(het_JD_vote3), bylabel("Left (N=580)") || ///
	(het_JD_vote4), bylabel("Liberal (N=889)") || ///	
	(het_JD_vote5), bylabel("Neutral (N=986)") || ///	
	(het_JD_vote6), bylabel("Conservative (N=1,017)") || ///	
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.05 0.15)) xlab(-0.05(0.05)0.15) ///
	legend(rows(1) position(6) xoffset(-15)) ysize(6) xsize(5.2)   ///
	keep(Treatment_GC) headings(1="{bf: Education}" 4="{bf: HH income}" 8="{bf: Voting: Right/Left}" 11="{bf: Voting: Liberal/Conservative}", labcolor(black))
graph save "$outputpath/Figures/Fig_4B", replace
graph export "$outputpath/Figures/Fig_4B.pdf", replace

********************************
***Control means (added manually to Figure 4)
use "$cleandatapath/Experiment2.dta", clear
recode Treatment (1=0) (2=1), gen(Treatment_GC)

**gender

sum JD_ifnice if Treatment_GC==0 & Female==0
sum JD_ifnice if Treatment_GC==0 & Female==1

**age

sum JD_ifnice if Treatment_GC==0 & age_cat==1
sum JD_ifnice if Treatment_GC==0 & age_cat==2
sum JD_ifnice if Treatment_GC==0 & age_cat==3
sum JD_ifnice if Treatment_GC==0 & age_cat==4
sum JD_ifnice if Treatment_GC==0 & age_cat==5
sum JD_ifnice if Treatment_GC==0 & age_cat==6


**size of municipality

sum JD_ifnice if Treatment_GC==0 & size_place==1
sum JD_ifnice if Treatment_GC==0 & size_place==2            
sum JD_ifnice if Treatment_GC==0 & size_place==3            
sum JD_ifnice if Treatment_GC==0 & size_place==4            
sum JD_ifnice if Treatment_GC==0 & size_place==5  

**edu 

sum JD_ifnice if Treatment_GC==0 & edu_5==1 /*edu_5=1 if edu=1 or edu=2*/
sum JD_ifnice if Treatment_GC==0 & edu==3                
sum JD_ifnice if Treatment_GC==0 & edu==4                

**HH income - quartiles

sum JD_ifnice if Treatment_GC==0 & HHinc_1==1
sum JD_ifnice if Treatment_GC==0 & HHinc_2==1
sum JD_ifnice if Treatment_GC==0 & HHinc_3==1
sum JD_ifnice if Treatment_GC==0 & HHinc_4==1


**voting

sum JD_ifnice if Treatment_GC==0 & voting_p_psl==1
sum JD_ifnice if Treatment_GC==0 & voting_p_psl==2               
sum JD_ifnice if Treatment_GC==0 & voting_p_psl==3               

sum JD_ifnice if Treatment_GC==0 & voting_p_lnk==1
sum JD_ifnice if Treatment_GC==0 & voting_p_lnk==2               
sum JD_ifnice if Treatment_GC==0 & voting_p_lnk==3

*****************************************************************************************************************************************
******** FIGURE 5. DESTRUCTIVE BEHAVIOR IN GROUPS, EXPERIMENT 3 (REPRESENTATIVE SAMPLE OF ADULT POPULATION)
*****************************************************************************************************************************************

use "$cleandatapath/Experiment3.dta", clear


preserve
 
*expand 2, gen(expand) 
keep if completed_experiment==1
keep if COSTLY==1

		gen order_help=1 if Treatment_GC==0 
		replace order_help=2.5 if Treatment_GC==1 
		
		collapse  (mean) mean_antisocial = antisocial  (sd) sd_antisocial = antisocial (count) n_antisocial = antisocial , by(order_help)
				
		*generate the values of 95% confidence intervals 
			gen hi_antisocial = mean_antisocial + invttail(n_antisocial-1,0.025)*(sd_antisocial / sqrt(n_antisocial))
			gen low_antisocial= mean_antisocial - invttail(n_antisocial-1,0.025)*(sd_antisocial / sqrt(n_antisocial))			
			
	*generate the label
		gen mean_antisocialhelp=mean_antisocial
		format mean_antisocialhelp %9.3f
		
		*graph begin
		graph twoway (bar mean_antisocial order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_antisocial order_help if order_help==2.5, color(gs5) lcolor(black)) ///
		(rcap hi_antisocial low_antisocial order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_antisocial order_help , ///
		msymbol(none) mlabel(mean_antisocialhelp) mlabposition(12) mlabgap(*26) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.1)) ytitle("Proportion of destructive choices in JDG with prosocial option") ylabel(0.0(0.02)0.1, nogrid ang(h)) xscale(r(0 3)) xlab(1 "Individual" 2.5 `" "GroupContext" "_Hidden" "', labsize(medsmall) noticks) ///
		xsize(3) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		
graph save "$outputpath/Figures/Fig_5", replace
graph export "$outputpath/Figures/Fig_5.pdf", replace
		
		
restore

*****************************************************************************************************************************************
********FIGURE A.1: PAYOFF MATRICES
*****************************************************************************************************************************************

*** Only in the paper

*****************************************************************************************************************************************
******** FIGURE A.2: BELIEFS REGARDING HOW MANY OF THE OTHER TWO GROUP MEMBERS CHOSE TO DESTROY, EXPERIMENT 1 (SLOVAKIA, UNIVERSITY STUDENTS)
*****************************************************************************************************************************************

use "$cleandatapath/Experiment1.dta", clear

preserve

by Treatment, sort: tab JD_bel_twooth

***Panel A: GroupContext_Hidden condition
histogram JD_bel_twooth if Treatment==2, discrete fraction yscale(r(0 0.8)) ylabel(0.0(0.1)0.8, nogrid ang(h))  xlab(0 "0/2 want to destroy" 1 "1/2 wants to destroy" 2 "2/2 want to destroy") xtitle("", yoffset(-3))

		graph save "$outputpath/Figures/Fig_A2_A", replace
		graph export "$outputpath/Figures/Fig_A2_A.pdf", replace

***Panel B: GroupContext_Observed condition
histogram JD_bel_twooth if Treatment==3, discrete fraction yscale(r(0 0.8)) ylabel(0.0(0.1)0.8, nogrid ang(h))  xlab(0 "0/2 want to destroy" 1 "1/2 wants to destroy" 2 "2/2 want to destroy")  xtitle("", yoffset(-3))

		graph save "$outputpath/Figures/Fig_A2_B", replace
		graph export "$outputpath/Figures/Fig_A2_B.pdf", replace

		

restore

*****************************************************************************************************************************************
******** FIGURE A.3: EFFECTS OF GROUP CONTEXT ON DESTRUCTIVE BEHAVIOR IN THE JOY OF DESTRUCTION GAME (JDG)—HETEROGENEITY ACROSS SUB-GROUPS, EXPERIMENT 2 (REPRESENTATIVE SAMPLE OF ADULT POPULATION)
*****************************************************************************************************************************************

use "$cleandatapath/Experiment2.dta", clear
recode Treatment (1=0) (2=1), gen(Treatment_GC)

eststo clear

**gender

quietly eststo het_JD_gender1: reg JD_index Treatment_GC if Female==0, robust
quietly eststo het_JD_gender2: reg JD_index Treatment_GC if Female==1, robust

**age

quietly eststo het_JD_age1: reg JD_index Treatment_GC if age_cat==1, robust
quietly eststo het_JD_age2: reg JD_index Treatment_GC if age_cat==2, robust
quietly eststo het_JD_age3: reg JD_index Treatment_GC if age_cat==3, robust
quietly eststo het_JD_age4: reg JD_index Treatment_GC if age_cat==4, robust
quietly eststo het_JD_age5: reg JD_index Treatment_GC if age_cat==5, robust
quietly eststo het_JD_age6: reg JD_index Treatment_GC if age_cat==6, robust


**size of municipality

quietly eststo het_JD_mun1: reg JD_index Treatment_GC if size_place==1, robust
quietly eststo het_JD_mun2: reg JD_index Treatment_GC if size_place==2, robust            
quietly eststo het_JD_mun3: reg JD_index Treatment_GC if size_place==3, robust            
quietly eststo het_JD_mun4: reg JD_index Treatment_GC if size_place==4, robust            
quietly eststo het_JD_mun5: reg JD_index Treatment_GC if size_place==5, robust  

**edu 

quietly eststo het_JD_educ1: reg JD_index Treatment_GC if edu_5==1, robust /*edu_5=1 if edu=1 or edu=2*/
quietly eststo het_JD_educ2: reg JD_index Treatment_GC if edu==3, robust                
quietly eststo het_JD_educ3: reg JD_index Treatment_GC if edu==4, robust                

**HH income - quartiles

quietly eststo het_JD_hhinc1: reg JD_index Treatment_GC if HHinc_1==1, robust
quietly eststo het_JD_hhinc2: reg JD_index Treatment_GC if HHinc_2==1, robust
quietly eststo het_JD_hhinc3: reg JD_index Treatment_GC if HHinc_3==1, robust
quietly eststo het_JD_hhinc4: reg JD_index Treatment_GC if HHinc_4==1, robust


**voting

quietly eststo het_JD_vote1: reg JD_index Treatment_GC if voting_p_psl==1, robust
quietly eststo het_JD_vote2: reg JD_index Treatment_GC if voting_p_psl==2, robust               
quietly eststo het_JD_vote3: reg JD_index Treatment_GC if voting_p_psl==3, robust               

quietly eststo het_JD_vote4: reg JD_index Treatment_GC if voting_p_lnk==1, robust
quietly eststo het_JD_vote5: reg JD_index Treatment_GC if voting_p_lnk==2, robust               
quietly eststo het_JD_vote6: reg JD_index Treatment_GC if voting_p_lnk==3, robust

***Figure A3_A (left part)
  coefplot ///
    (het_JD_gender1, label("") msymbol(O)), bylabel("Male (N=1,895)") || ///
	(het_JD_gender2), bylabel("Female (N=2,348)") || ///
	(het_JD_age1), bylabel("18-24 (N=398)") || ///
	(het_JD_age2), bylabel("25-34 (N=944)") || ///
	(het_JD_age3), bylabel("35-44 (N=1,008)") || ///
	(het_JD_age4), bylabel("45-54 (N=796)") || ///
	(het_JD_age5), bylabel("55-64 (N=746)") || ///
	(het_JD_age6), bylabel("65+ (N=351)") || ///
	(het_JD_mun1), bylabel("<1,000 (N=594)") || ///
	(het_JD_mun2), bylabel("1,000-5,000 (N=1,106)") || ///
	(het_JD_mun3), bylabel("5,000-20,000 (N=727)") || ///
	(het_JD_mun4), bylabel("20,000-100,000 (N=1,189)") || ///
	(het_JD_mun5), bylabel(">100,000 (N=627)") || ///
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.05 0.15)) ///
	legend(rows(1) position(6)  xoffset(-15)) ysize(6) xsize(5)   ///
	keep(Treatment_GC) headings(1="{bf: Gender}" 3="{bf: Age}" 9="{bf: Municipality size}", labcolor(black))
graph save "$outputpath/Figures/Fig_A3_A", replace
graph export "$outputpath/Figures/Fig_A3_A.pdf", replace     

***Figure A3_B (right part)
    coefplot ///
   	(het_JD_educ1, label("") msymbol(O)), bylabel("Primary/Lower Secondary (N=1,144)") || ///
	(het_JD_educ2), bylabel("Upper Secondary (N=1,772)") || ///
	(het_JD_educ3), bylabel("Tertiary (N=1,327)") || ///
	(het_JD_hhinc1, label(Effect of GC_Hidden) msymbol(O)), bylabel("1st quartile (N=1,066)") || ///
	(het_JD_hhinc2), bylabel("2nd quartile (N=1,272)") || ///
	(het_JD_hhinc3), bylabel("3rd quartile (N=1,406)") || ///
	(het_JD_hhinc4), bylabel("4th quartile (N=499)") || ///
	(het_JD_vote1), bylabel("Right (N=1,405)") || ///
	(het_JD_vote2), bylabel("Middle (N=907)") || ///
	(het_JD_vote3), bylabel("Left (N=580)") || ///
	(het_JD_vote4), bylabel("Liberal (N=889)") || ///	
	(het_JD_vote5), bylabel("Neutral (N=986)") || ///	
	(het_JD_vote6), bylabel("Conservative (N=1,017)") || ///	
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.05 0.15)) xlab(-0.05(0.05)0.15) ///
	legend(rows(1) position(6) xoffset(-15)) ysize(6) xsize(5.2)   ///
	keep(Treatment_GC) headings(1="{bf: Education}" 4="{bf: HH income}" 8="{bf: Voting: Right/Left}" 11="{bf: Voting: Liberal/Conservative}", labcolor(black))
graph save "$outputpath/Figures/Fig_A3_B", replace
graph export "$outputpath/Figures/Fig_A3_B.pdf", replace

********************************
***Control means (added manually to Figure A.3)
use "$cleandatapath/Experiment2.dta", clear
recode Treatment (1=0) (2=1), gen(Treatment_GC)

**gender

sum JD_index if Treatment_GC==0 & Female==0
sum JD_index if Treatment_GC==0 & Female==1

**age

sum JD_index if Treatment_GC==0 & age_cat==1
sum JD_index if Treatment_GC==0 & age_cat==2
sum JD_index if Treatment_GC==0 & age_cat==3
sum JD_index if Treatment_GC==0 & age_cat==4
sum JD_index if Treatment_GC==0 & age_cat==5
sum JD_index if Treatment_GC==0 & age_cat==6


**size of municipality

sum JD_index if Treatment_GC==0 & size_place==1
sum JD_index if Treatment_GC==0 & size_place==2            
sum JD_index if Treatment_GC==0 & size_place==3            
sum JD_index if Treatment_GC==0 & size_place==4            
sum JD_index if Treatment_GC==0 & size_place==5  

**edu 

sum JD_index if Treatment_GC==0 & edu_5==1 /*edu_5=1 if edu=1 or edu=2*/
sum JD_index if Treatment_GC==0 & edu==3                
sum JD_index if Treatment_GC==0 & edu==4                

**HH income - quartiles

sum JD_index if Treatment_GC==0 & HHinc_1==1
sum JD_index if Treatment_GC==0 & HHinc_2==1
sum JD_index if Treatment_GC==0 & HHinc_3==1
sum JD_index if Treatment_GC==0 & HHinc_4==1


**voting

sum JD_index if Treatment_GC==0 & voting_p_psl==1
sum JD_index if Treatment_GC==0 & voting_p_psl==2               
sum JD_index if Treatment_GC==0 & voting_p_psl==3               

sum JD_index if Treatment_GC==0 & voting_p_lnk==1
sum JD_index if Treatment_GC==0 & voting_p_lnk==2               
sum JD_index if Treatment_GC==0 & voting_p_lnk==3

*****************************************************************************************************************************************
********FIGURE A.4: EFFECTS OF GROUP CONTEXT ON NON-COOPERATIVE BEHAVIOR IN THE PRISONER'S DILEMMA GAME (PDG)—HETEROGENEITY ACROSS SUB-GROUPS, EXPERIMENT 2 (REPRESENTATIVE SAMPLE OF ADULT POPULATION)
*****************************************************************************************************************************************


use "$cleandatapath/Experiment2.dta", clear

eststo clear

**gender

quietly eststo het_PD_gender1: reg PD_index Treatment if Female==0, robust
quietly eststo het_PD_gender2: reg PD_index Treatment if Female==1, robust

**age

quietly eststo het_PD_age1: reg PD_index Treatment if age_cat==1, robust
quietly eststo het_PD_age2: reg PD_index Treatment if age_cat==2, robust
quietly eststo het_PD_age3: reg PD_index Treatment if age_cat==3, robust
quietly eststo het_PD_age4: reg PD_index Treatment if age_cat==4, robust
quietly eststo het_PD_age5: reg PD_index Treatment if age_cat==5, robust
quietly eststo het_PD_age6: reg PD_index Treatment if age_cat==6, robust

**size of municipality

quietly eststo het_PD_mun1: reg PD_index Treatment if size_place==1, robust
quietly eststo het_PD_mun2: reg PD_index Treatment if size_place==2, robust            
quietly eststo het_PD_mun3: reg PD_index Treatment if size_place==3, robust            
quietly eststo het_PD_mun4: reg PD_index Treatment if size_place==4, robust            
quietly eststo het_PD_mun5: reg PD_index Treatment if size_place==5, robust  

**edu 

quietly eststo het_PD_educ1: reg PD_index Treatment if edu_5==1, robust /*edu_5=1 if edu=1 or edu=2*/
quietly eststo het_PD_educ2: reg PD_index Treatment if edu==3, robust                
quietly eststo het_PD_educ3: reg PD_index Treatment if edu==4, robust                

**HH income - quartiles

quietly eststo het_PD_hhinc1: reg PD_index Treatment if HHinc_1==1, robust
quietly eststo het_PD_hhinc2: reg PD_index Treatment if HHinc_2==1, robust
quietly eststo het_PD_hhinc3: reg PD_index Treatment if HHinc_3==1, robust
quietly eststo het_PD_hhinc4: reg PD_index Treatment if HHinc_4==1, robust

       
**voting

quietly eststo het_PD_vote1: reg PD_index Treatment if voting_p_psl==1, robust
quietly eststo het_PD_vote2: reg PD_index Treatment if voting_p_psl==2, robust               
quietly eststo het_PD_vote3: reg PD_index Treatment if voting_p_psl==3, robust               

quietly eststo het_PD_vote4: reg PD_index Treatment if voting_p_lnk==1, robust
quietly eststo het_PD_vote5: reg PD_index Treatment if voting_p_lnk==2, robust               
quietly eststo het_PD_vote6: reg PD_index Treatment if voting_p_lnk==3, robust

***Figure A4_A (left part)
   coefplot ///
    (het_PD_gender1, label("") msymbol(O)), bylabel("Male (N=1,895)") || ///
	(het_PD_gender2), bylabel("Female (N=2,348)") || ///
	(het_PD_age1), bylabel("18-24 (N=398)") || ///
	(het_PD_age2), bylabel("25-34 (N=944)") || ///
	(het_PD_age3), bylabel("35-44 (N=1,008)") || ///
	(het_PD_age4), bylabel("45-54 (N=796)") || ///
	(het_PD_age5), bylabel("55-64 (N=746)") || ///
	(het_PD_age6), bylabel("65+ (N=351)") || ///
	(het_PD_mun1), bylabel("<1,000 (N=594)") || ///
	(het_PD_mun2), bylabel("1,000-5,000 (N=1,106)") || ///
	(het_PD_mun3), bylabel("5,000-20,000 (N=727)") || ///
	(het_PD_mun4), bylabel("20,000-100,000 (N=1,189)") || ///
	(het_PD_mun5), bylabel(">100,000 (N=627)") || ///
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.05 0.15)) ///
	legend(rows(1) position(6)  xoffset(-15)) ysize(6) xsize(5)   ///
	keep(Treatment) headings(1="{bf: Gender}" 3="{bf: Age}" 9="{bf: Municipality size}", labcolor(black))
graph save "$outputpath/Figures/Fig_A4_A", replace
graph export "$outputpath/Figures/Fig_A4_A.pdf", replace     
    
***Figure A4_B (right part)
      coefplot ///
   	(het_PD_educ1, label("") msymbol(O)), bylabel("Primary/Lower Secondary (N=1,144)") || ///
	(het_PD_educ2), bylabel("Upper Secondary (N=1,772)") || ///
	(het_PD_educ3), bylabel("Tertiary (N=1,327)") || ///
	(het_PD_hhinc1), bylabel("1st quartile (N=1,066)") || ///
	(het_PD_hhinc2), bylabel("2nd quartile (N=1,272)") || ///
	(het_PD_hhinc3), bylabel("3rd quartile (N=1,406)") || ///
	(het_PD_hhinc4), bylabel("4th quartile (N=499)") || ///
	(het_PD_vote1), bylabel("Right (N=1,405)") || ///
	(het_PD_vote2), bylabel("Middle (N=907)") || ///
	(het_PD_vote3), bylabel("Left (N=580)") || ///
	(het_PD_vote4), bylabel("Liberal (N=889)") || ///	
	(het_PD_vote5), bylabel("Neutral (N=986)") || ///	
	(het_PD_vote6), bylabel("Conservative (N=1,017)") || ///	
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.05 0.15)) xlab(-0.05(0.05)0.15) ///
	legend(rows(1) position(6) xoffset(-15)) ysize(6) xsize(5.2)   ///
	keep(Treatment) headings(1="{bf: Education}" 4="{bf: HH income}" 8="{bf: Voting: Right/Left}" 11="{bf: Voting: Liberal/Conservative}", labcolor(black))
	graph save "$outputpath/Figures/Fig_A4_B", replace
graph export "$outputpath/Figures/Fig_A4_B.pdf", replace   

********************************
***Control means (added manually to Figure A.4)
use "$cleandatapath/Experiment2.dta", clear
recode Treatment (1=0) (2=1), gen(Treatment_GC)

**gender

sum PD_index if Treatment_GC==0 & Female==0
sum PD_index if Treatment_GC==0 & Female==1

**age

sum PD_index if Treatment_GC==0 & age_cat==1
sum PD_index if Treatment_GC==0 & age_cat==2
sum PD_index if Treatment_GC==0 & age_cat==3
sum PD_index if Treatment_GC==0 & age_cat==4
sum PD_index if Treatment_GC==0 & age_cat==5
sum PD_index if Treatment_GC==0 & age_cat==6


**size of municipality

sum PD_index if Treatment_GC==0 & size_place==1
sum PD_index if Treatment_GC==0 & size_place==2            
sum PD_index if Treatment_GC==0 & size_place==3            
sum PD_index if Treatment_GC==0 & size_place==4            
sum PD_index if Treatment_GC==0 & size_place==5  

**edu 

sum PD_index if Treatment_GC==0 & edu_5==1 /*edu_5=1 if edu=1 or edu=2*/
sum PD_index if Treatment_GC==0 & edu==3                
sum PD_index if Treatment_GC==0 & edu==4                

**HH income - quartiles

sum PD_index if Treatment_GC==0 & HHinc_1==1
sum PD_index if Treatment_GC==0 & HHinc_2==1
sum PD_index if Treatment_GC==0 & HHinc_3==1
sum PD_index if Treatment_GC==0 & HHinc_4==1


**voting

sum PD_index if Treatment_GC==0 & voting_p_psl==1
sum PD_index if Treatment_GC==0 & voting_p_psl==2               
sum PD_index if Treatment_GC==0 & voting_p_psl==3               

sum PD_index if Treatment_GC==0 & voting_p_lnk==1
sum PD_index if Treatment_GC==0 & voting_p_lnk==2               
sum PD_index if Treatment_GC==0 & voting_p_lnk==3


*****************************************************************************************************************************************
********FIGURE A.5: EFFECTS OF GROUP CONTEXT ON DESTRUCTIVE BEHAVIOR IN THE JOY OF DESTRUCTION GAME (JDG) WITH PROSOCIAL OPTION—HETEROGENEITY ACROSS SUB-GROUPS, EXPERIMENT 3 (REPRESENTATIVE SAMPLE OF ADULT POPULATION)
*****************************************************************************************************************************************

use "$cleandatapath/Experiment3.dta", clear

set scheme lean2 

eststo clear

*preserve
keep if completed_experiment==1
keep if COSTLY==1

*Number of observations (to be added into the legend in the left-most column)
tab Treatment

sum Treatment if Female==0
sum Treatment if Female==1

sum Treatment if age_cat==1
sum Treatment if age_cat==2
sum Treatment if age_cat==3
sum Treatment if age_cat==4
sum Treatment if age_cat==5
sum Treatment if age_cat==6


sum Treatment if size_place==1
sum Treatment if size_place==2
sum Treatment if size_place==3
sum Treatment if size_place==4
sum Treatment if size_place==5

sum Treatment if edu_cat==1
sum Treatment if edu_cat==2
sum Treatment if edu_cat==3

sum Treatment if HHinc_cat==1
sum Treatment if HHinc_cat==2
sum Treatment if HHinc_cat==3
sum Treatment if HHinc_cat==4

********Underlying regressions
**all

quietly eststo het_JD_all: reg antisocial Treatment_GC, robust

**gender

quietly eststo het_JD_gender1: reg antisocial Treatment_GC if Female==0, robust
quietly eststo het_JD_gender2: reg antisocial Treatment_GC if Female==1, robust

**age

quietly eststo het_JD_age1: reg antisocial Treatment_GC if age_cat==1, robust
quietly eststo het_JD_age2: reg antisocial Treatment_GC if age_cat==2, robust
quietly eststo het_JD_age3: reg antisocial Treatment_GC if age_cat==3, robust
quietly eststo het_JD_age4: reg antisocial Treatment_GC if age_cat==4, robust
quietly eststo het_JD_age5: reg antisocial Treatment_GC if age_cat==5, robust
quietly eststo het_JD_age6: reg antisocial Treatment_GC if age_cat==6, robust


**size of municipality

quietly eststo het_JD_mun1: reg antisocial Treatment_GC if size_place==1, robust
quietly eststo het_JD_mun2: reg antisocial Treatment_GC if size_place==2, robust            
quietly eststo het_JD_mun3: reg antisocial Treatment_GC if size_place==3, robust            
quietly eststo het_JD_mun4: reg antisocial Treatment_GC if size_place==4, robust            
quietly eststo het_JD_mun5: reg antisocial Treatment_GC if size_place==5, robust  

**edu 

quietly eststo het_JD_educ1: reg antisocial Treatment_GC if edu_cat==1, robust /*edu_5=1 if edu=1 or edu=2*/
quietly eststo het_JD_educ2: reg antisocial Treatment_GC if edu_cat==2, robust                
quietly eststo het_JD_educ3: reg antisocial Treatment_GC if edu_cat==3, robust                

**HH income - quartiles

quietly eststo het_JD_hhinc1: reg antisocial Treatment_GC if HHinc_cat==1, robust
quietly eststo het_JD_hhinc2: reg antisocial Treatment_GC if HHinc_cat==2, robust
quietly eststo het_JD_hhinc3: reg antisocial Treatment_GC if HHinc_cat==3, robust
quietly eststo het_JD_hhinc4: reg antisocial Treatment_GC if HHinc_cat==4, robust
  


  coefplot ///
    (het_JD_all, label("") msymbol(O)), bylabel("All (N=1689)")|| ///
    (het_JD_gender1, label("Effect of GroupContext") msymbol(O)), bylabel("Male (N=826)") || ///
	(het_JD_gender2), bylabel("Female (N=863)") || ///
	(het_JD_age1), bylabel("18-24 (N=193)") || ///
	(het_JD_age2), bylabel("25-34 (N=392)") || ///
	(het_JD_age3), bylabel("35-44 (N=437)") || ///
	(het_JD_age4), bylabel("45-54 (N=308)") || ///
	(het_JD_age5), bylabel("55-64 (N=232)") || ///
	(het_JD_age6), bylabel("65+ (N=127)") || ///
	(het_JD_mun1), bylabel("<1,000 (N=200)") || ///
	(het_JD_mun2), bylabel("1,000-5,000 (N=459)") || ///
	(het_JD_mun3), bylabel("5,000-20,000 (N=318)") || ///
	(het_JD_mun4), bylabel("20,000-100,000 (N=503)") || ///
	(het_JD_mun5), bylabel(">100,000 (N=209)") || ///
	(het_JD_educ1, label("") msymbol(O)), bylabel("Primary/Lower Secondary (N=298)") || ///
	(het_JD_educ2), bylabel("Upper Secondary (N=854)") || ///
	(het_JD_educ3), bylabel("Tertiary (N=537)") || ///
	(het_JD_hhinc1, label(Effect of GroupContext) msymbol(O)), bylabel("1st quartile (N=408)") || ///
	(het_JD_hhinc2), bylabel("2nd quartile (N=386)") || ///
	(het_JD_hhinc3), bylabel("3rd quartile (N=308)") || ///
	(het_JD_hhinc4), bylabel("4th quartile (N=296)") || ///
	, ///
	xline(0, lpattern(dash)) ///
	bycoefs ///
	grid(none) ///
	xtitle("") ///
	xscale(r(-0.06 0.12)) xlab(-0.08(0.02)0.12) ///
	legend(rows(1) position(6)  xoffset(-15))  xsize(6)   ///
	keep(Treatment_GC) headings(1="{bf: All}" 2="{bf: Gender}" 4="{bf: Age}" 10="{bf: Municipality size}" 15="{bf: Education}" 18="{bf: HH income}", labsize(small) labcolor(black))

graph save "$outputpath/Figures/Fig_A5", replace
graph export "$outputpath/Figures/Fig_A5.pdf", replace		   


     
*Control mean (to be added manually to the Figure)

sum antisocial if Treatment_GC==0

sum antisocial if Female==0 & Treatment_GC==0
sum antisocial if Female==1 & Treatment_GC==0

sum antisocial if age_cat==1 & Treatment_GC==0
sum antisocial if age_cat==2 & Treatment_GC==0
sum antisocial if age_cat==3 & Treatment_GC==0
sum antisocial if age_cat==4 & Treatment_GC==0
sum antisocial if age_cat==5 & Treatment_GC==0
sum antisocial if age_cat==6 & Treatment_GC==0


sum antisocial if size_place==1 & Treatment_GC==0
sum antisocial if size_place==2 & Treatment_GC==0
sum antisocial if size_place==3 & Treatment_GC==0
sum antisocial if size_place==4 & Treatment_GC==0
sum antisocial if size_place==5 & Treatment_GC==0

sum antisocial if edu_cat==1 & Treatment_GC==0
sum antisocial if edu_cat==2 & Treatment_GC==0
sum antisocial if edu_cat==3 & Treatment_GC==0

sum antisocial if HHinc_cat==1 & Treatment_GC==0
sum antisocial if HHinc_cat==2 & Treatment_GC==0
sum antisocial if HHinc_cat==3 & Treatment_GC==0
sum antisocial if HHinc_cat==4 & Treatment_GC==0


	 
*restore

*****************************************************************************************************************************************
********FIGURE A.6: DESTRUCTIVE BEHAVIOR IN GROUPS, PILOT EXPERIMENT 1 (SLOVAKIA, ADOLESCENTS)
*****************************************************************************************************************************************

use "$cleandatapath/Pilot_Experiment1.dta", replace

preserve
		gen order_help=1 if  Treatment==1 
		replace order_help=3 if Treatment==2 
		replace order_help=5 if Treatment==3  
		replace order_help=7 if Treatment==4  
		
		recode Treatment (1=0) (2=1) (3/4=0), gen(Treatment2)
		recode Treatment (1/2=0) (3=1) (4=0), gen(Treatment3)
		recode Treatment (1/3=0) (4=1) , gen(Treatment4)
		reg JD_uncond Treatment2 Treatment3 Treatment4, cluster(ID_cluster)
		lincomest _cons+Treatment2 
		quietly: reg JD_uncond Treatment2 Treatment3 Treatment4, cluster(ID_cluster)
		lincomest _cons+Treatment3
		quietly: reg JD_uncond Treatment2 Treatment3 Treatment4, cluster(ID_cluster)
		lincomest _cons+Treatment4

		ci means JD_uncond if Treatment==1
		ci proportions JD_uncond if Treatment==1

		
		collapse  (mean) mean_JD = JD_uncond (sd) sd_JD = JD_uncond (count) n_JD = JD_uncond , by(order_help Treatment)
										
		
		*generate the values of 95% confidence intervals using the clustered confidence intervals from the regression above
			gen low_JD= .2459662	if Treatment==1	
			gen hi_JD = .3936734 if Treatment==1
			replace low_JD= .4071608 if Treatment==2	
			replace hi_JD = .4782457 if Treatment==2
			replace low_JD= .3639131 if Treatment==3	
     		replace hi_JD = .5348211 if Treatment==3
			replace low_JD= .3513824 if Treatment==4	
			replace hi_JD = .4809875 if Treatment==4
			
	*generate the label
		gen mean_JD_uncondhelp=mean_JD
		format mean_JD_uncondhelp %9.2f
		
		*graph begin
		graph twoway (bar mean_JD order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_JD order_help if order_help==3, color(gs10) lcolor(black)) ///
		(bar mean_JD order_help if order_help==5, color(gs10) lcolor(black)) ///
		(bar mean_JD order_help if order_help==7, color(gs2) lcolor(black)) ///
		(rcap hi_JD low_JD order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_JD order_help if Treatment==1 | Treatment==4, ///
		msymbol(none) mlabel(mean_JD_uncondhelp) mlabposition(12) mlabgap(*14) mlabcolor(black)) /// 
		(scatter mean_JD order_help if Treatment==2, ///
		msymbol(none) mlabel(mean_JD_uncondhelp) mlabposition(12) mlabgap(*10) mlabcolor(black)) ///
		(scatter mean_JD order_help if Treatment==3, ///
		msymbol(none) mlabel(mean_JD_uncondhelp) mlabposition(12) mlabgap(*16) mlabcolor(black)),  ///
		yscale(r(0.0 0.7)) ytitle("Proportion of destructive choices in JDG") ylabel(0.0(0.1)0.7, nogrid ang(h)) xscale(r(0 8)) xlab(1 "Individual" 3 "GroupContext_1" 5  "GroupContext_2" 7 "Group", labsize(medsmall) noticks) ///
		xsize(6) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		graph save "$outputpath/Figures/Fig_A6", replace
		graph export "$outputpath/Figures/Fig_A6.pdf", replace
		
restore

*****************************************************************************************************************************************
********FIGURE A.7: DESTRUCTIVE BEHAVIOR IN GROUPS, PILOT EXPERIMENT 2 (UGANDA, ADOLESCENTS)
*****************************************************************************************************************************************

use "$cleandatapath/Pilot_Experiment2.dta", replace

preserve
		gen order_help=1 if  Treatment==1 
		replace order_help=3 if Treatment==2 
		replace order_help=5 if Treatment==4 
		
		collapse  (mean) mean_JD = JD_uncond  (sd) sd_JD = JD_uncond (count) n_JD = JD_uncond , by(order_help)
									
			
		*generate the values of 95% confidence intervals
			gen hi_JD = mean_JD + invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))
			gen low_JD= mean_JD - invttail(n_JD-1,0.025)*(sd_JD / sqrt(n_JD))			
			
	*generate the label
		gen mean_JD_uncondhelp=mean_JD
		format mean_JD_uncondhelp %9.2f
		
		*graph begin
		graph twoway (bar mean_JD order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_JD order_help if order_help==3, color(gs10) lcolor(black)) ///
		(bar mean_JD order_help if order_help==5, color(gs5) lcolor(black)) ///
		(rcap hi_JD low_JD order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_JD order_help , ///
		msymbol(none) mlabel(mean_JD_uncondhelp) mlabposition(12) mlabgap(*10) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.7)) ytitle("Proportion of destructive choices in JDG") ylabel(0.0(0.1)0.7, nogrid ang(h)) xscale(r(0 6)) xlab(1 "Individual" 3 "GroupContext_1" 5 "Group", labsize(medsmall) noticks) ///
		xsize(6) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(black))
		*graph end	
		
		graph save "$outputpath/Figures/Fig_A7", replace
		graph export "$outputpath/Figures/Fig_A7.pdf", replace
		
		
restore

*****************************************************************************************************************************************
********FIGURE A.8: DESTRUCTIVE BEHAVIOR IN GROUPS, SUPPLEMENTARY EXPERIMENT (SLOVAKIA, REPRESENTATIVE SAMPLE OF POPULATION AGE 50-65)
*****************************************************************************************************************************************


use "$cleandatapath/Supplementary_Experiment.dta", clear

preserve
 
		gen order_help=1 if Treatment==0 
		replace order_help=2.5 if Treatment==1 
		
		collapse  (mean) mean_antisocial = antisocial  (sd) sd_antisocial = antisocial (count) n_antisocial = antisocial , by(order_help)
		*browse
										
		*generate the values of mean +-standard errors
			*gen hi_antisocial = mean_antisocial + (sd_antisocial / sqrt(n_antisocial))
			*gen low_antisocial = mean_antisocial -(sd_antisocial / sqrt(n_antisocial))
			
		*generate the values of 95% confidence intervals instead
			gen hi_antisocial = mean_antisocial + invttail(n_antisocial-1,0.025)*(sd_antisocial / sqrt(n_antisocial))
			gen low_antisocial= mean_antisocial - invttail(n_antisocial-1,0.025)*(sd_antisocial / sqrt(n_antisocial))			
			
	*generate the label
		gen mean_antisocialhelp=mean_antisocial
		format mean_antisocialhelp %9.3f
		
		*graph begin
		graph twoway (bar mean_antisocial order_help if order_help==1, color(gs15) lcolor(black)) ///
		(bar mean_antisocial order_help if order_help==2.5, color(gs5) lcolor(black)) ///
		(rcap hi_antisocial low_antisocial order_help , bgcolor(white) color(gs4)) ///	
		(scatter mean_antisocial order_help , ///
		msymbol(none) mlabel(mean_antisocialhelp) mlabposition(12) mlabgap(*34) mlabcolor(black)) ,  ///
		yscale(r(0.0 0.1)) ytitle("Proportion of destructive choices in JDG") ylabel(0.0(0.02)0.1, nogrid ang(h)) xscale(r(0 3)) xlab(1 `" "Variant A:" "without prosocial option" "' 2.5 `" "Variant B:" "with prosocial option" "', labsize(medsmall) noticks) ///
		xsize(3) xtitle("", yoffset(-1.5)) legend(off) graphregion(fcolor(white) lcolor(white))
		*graph end	
		
		graph save "$outputpath/Figures/Fig_A8", replace
		graph export "$outputpath/Figures/Fig_A8.pdf", replace

		
restore
******************************************************************************************************************

log close
